import { createSlice } from '@reduxjs/toolkit'
import type{PayloadAction} from '@reduxjs/toolkit'
import type { RootState } from '../store'

//创建子模块
const questionnaire = createSlice({
    name: 'questionnaire',
    initialState: {
        questions:[],
        answersId:[] as number[]
    },
    reducers: {
        setQuestions(state,action){
            state.questions = action.payload
        },
        setAnswersId(state,action:PayloadAction<number>){
            state.answersId.push(action.payload)
        }
    }
})
export const {setQuestions,setAnswersId} = questionnaire.actions

export default questionnaire.reducer
